<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div style="visibility:hidden">
  <svg></svg>
</div>
<script>
  description("Test that setting innerHTML and outerHTML properties works on SVG elements");
  var svg = document.getElementsByTagName('svg')[0];

  svg.innerHTML = "<rect/>";
  shouldBeEqualToString("svg.innerHTML", '<rect></rect>');
  shouldBeEqualToString("svg.firstChild.namespaceURI", 'http://www.w3.org/2000/svg');

  svg.innerHTML = "<foreignobject><svg/></foreignobject>";
  shouldBeEqualToString("svg.innerHTML", '<foreignObject><svg></svg></foreignObject>');
  shouldBeEqualToString("svg.firstChild.namespaceURI", 'http://www.w3.org/2000/svg');
  shouldBeEqualToString("svg.firstChild.firstChild.namespaceURI", 'http://www.w3.org/2000/svg');

  svg.innerHTML = "<foreignobject><p>x</foreignobject>";
  shouldBeEqualToString("svg.innerHTML", '<foreignObject><p>x</p></foreignObject>');
  shouldBeEqualToString("svg.firstChild.namespaceURI", 'http://www.w3.org/2000/svg');
  shouldBeEqualToString("svg.firstChild.firstChild.namespaceURI", 'http://www.w3.org/1999/xhtml');

  svg.outerHTML = "<svg><circle/></svg>";
  var svg = document.getElementsByTagName('svg')[0];
  shouldBeEqualToString("svg.innerHTML", '<circle></circle>');
  shouldBeEqualToString("svg.firstChild.namespaceURI", 'http://www.w3.org/2000/svg');
</script>
</body>
</html>
